home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / addresslineedit.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.2 KB  |  124 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2002 Helge Deller <deller@gmx.de>
  4.                   2002 Lubos Lunak <llunak@suse.cz>
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. */
  21.  
  22. #ifndef KABC_ADDRESSLINEEDIT_H
  23. #define KABC_ADDRESSLINEEDIT_H
  24. // $Id: addresslineedit.h 465272 2005-09-29 09:47:40Z mueller $
  25.  
  26. #include <qobject.h>
  27. #include <qptrlist.h>
  28. #include <qtimer.h>
  29.  
  30. #include "klineedit.h"
  31. #include "kcompletion.h"
  32.  
  33. class KConfig;
  34.  
  35. namespace KABC {
  36.  
  37. class LdapSearch;
  38.  
  39. /**
  40.  * A lineedit with LDAP and kabc completion
  41.  *
  42.  * This lineedit is supposed to be used wherever the user types email addresses
  43.  * and might want a completion. You can simply use it as a replacement for
  44.  * KLineEdit or QLineEdit.
  45.  *
  46.  * You can enable or disable the lineedit at any time.
  47.  *
  48.  * @see AddressLineEdit::enableCompletion()
  49.  */
  50. class KABC_EXPORT AddressLineEdit : public KLineEdit
  51. {
  52.   Q_OBJECT
  53. public:
  54.   AddressLineEdit(QWidget* parent, bool useCompletion = true,
  55.         const char *name = 0L);
  56.   virtual ~AddressLineEdit();
  57.  
  58.   /**
  59.    * Reimplented for internal reasons.
  60.    * @ see KLineEdit::setFont()
  61.    */
  62.   virtual void setFont( const QFont& );
  63.  
  64.   static KConfig *config();
  65.  
  66. public slots:
  67.   /**
  68.    * Set cursor to end of line.
  69.    */
  70.   void cursorAtEnd();
  71.   /**
  72.    * Toggle completion.
  73.    */
  74.   void enableCompletion( bool enable );
  75.  
  76. protected:
  77.   /**
  78.    * Always call AddressLineEdit::loadAddresses() as the first thing.
  79.    * Use addAddress() to add addresses.
  80.    */
  81.   virtual void loadAddresses();
  82.   void addAddress( const QString& );
  83.   virtual void keyPressEvent(QKeyEvent*);
  84.   virtual void dropEvent(QDropEvent *e);
  85.   virtual void paste();
  86.   virtual void insert(const QString &t);
  87.   virtual void mouseReleaseEvent( QMouseEvent * e );
  88.   void doCompletion(bool ctrlT);
  89.  
  90. private slots:
  91.   void slotCompletion() { doCompletion(false); }
  92.   void slotPopupCompletion( const QString& );
  93.   void slotStartLDAPLookup();
  94.   void slotLDAPSearchData( const QStringList& );
  95.  
  96. private:
  97.   void init();
  98.   void startLoadingLDAPEntries();
  99.   void stopLDAPLookup();
  100.   QStringList addresses();
  101.   QStringList removeMailDupes( const QStringList& adrs );
  102.  
  103.   QString m_previousAddresses;
  104.   bool m_useCompletion;
  105.   bool m_completionInitialized;
  106.   bool m_smartPaste;
  107.   QString m_typedText; // unused
  108.  
  109.   static bool s_addressesDirty;
  110.   static KCompletion *s_completion;
  111.   static QTimer *s_LDAPTimer;
  112.   static LdapSearch *s_LDAPSearch;
  113.   static QString *s_LDAPText;
  114.   static AddressLineEdit *s_LDAPLineEdit;
  115.   static KConfig *s_config;
  116.  
  117. private:
  118.   class AddressLineEditPrivate* d;
  119. };
  120.  
  121. }
  122.  
  123. #endif        /* KABC_ADDRESSLINEEDIT_H */
  124.